#ifndef __MONKEYCOLLISION__H__
#define __MONKEYCOLLISION__H__

#include "cocos-ext.h"
#include "cocos2d.h"
#include "Config.h"
#include "../Model/Fruit.h"
#include "../Model/Monkey.h"
#include "../Model/Bough.h"
#include "../Model/Enemy.h"
#include "../HelloWorldScene.h"

USING_NS_CC;
USING_NS_CC_EXT;
using namespace cocos2d::gui;


class MonkeyCollision : public CCComponent
{
public:

	/// 
	/// Khoi tao
	/// 
	/// monkey: con khi
	/// ob: doi tuong dua vao
	///
	/// Khoi tao component cho doi tuong
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	MonkeyCollision(Monkey* monkey, int ob);


	/// 
	/// update
	/// 
	/// update trang thai moi cua qua
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	virtual void update(float delta);
	virtual void onEnter();

	/// 
	/// load music
	/// 
	/// phan am thanh
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	void fPreLoadMusic();

	/// 
	/// collision Fruit
	/// 
	/// Lay ra doi tuong fruit va thuc hien kiem tra va cham voi khi, neu chay xuong duoi man hinh thi xoa
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	void fCollisionFruit();


	/// 
	/// collision Bough
	/// 
	/// Lay ra doi tuong bough va thuc hien kiem tra va cham voi khi, kiem tra vuot qua khi de tinh diem, neu chay xuong duoi man hinh thi xoa
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	void fCollisionBough();

	/// 
	/// collision Enemy
	/// 
	/// Lay ra doi tuong enemy va thuc hien kiem tra va cham voi khi, kiem tra vuot qua khi de tinh diem, neu chay xuong duoi man hinh thi xoa
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	void fCollisionEnemy();

	/// 
	/// is collision
	/// 
	/// sp1: doi tuong boundingBox cua fruit, bough hoac enemy
	/// sp2: con khi
	///
	/// kiem tra va cham giua sp1 va sp2
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	bool fIsCollision(CCRect* sp1, CCArmature* sp2);

	/// 
	/// is over
	/// 
	/// sp1: doi tuong boundingBox cua bough hoac enemy
	/// sp2: con khi
	///
	/// kiem tra xem sp2 da vuot qua sp1 chua de tinh diem
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	bool fIsOver(CCRect* sp1, CCArmature* sp2);

	

private:

	int mIsDell;			// da xoa
	int mIsMonkeysEat;		// da bi khi an
	int mIsBreak;			// da gay canh
	int mIsEnemyColision;	// da va cham voi ke thu
	int mIsOver;			// da vuot qua ke thu hoac canh cay
	int mObject;

	Fruit* mFruit;
	Bough* mBough;
	Enemy* mEnemy;
	Monkey* mMonkey;

};

#endif //Va cham voi khi